unit Con_RepresMov;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DbTables, Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls,
  Buttons, ExtCtrls, TFlatButtonUnit;

type
  TFrmCon_RepresMov = class(TFrmConsulta)
    Label1: TLabel;
    dbgRepresMov: TDBGrid;
    btnGravar: TFlatButton;
    procedure BtnFecharClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure btnGravarClick(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Rep_Codigo: string;
    Repm_Data: TDateTime;
    Rep_Nome: string;
    Repm_Sequencia: Smallint;
  end;

var
  FrmCon_RepresMov: TFrmCon_RepresMov;

implementation
uses Dm, Biblio, clsRepresMov, Cad_RepresMov, menu;

{$R *.DFM}

var
  RepresMov: TRepresMov;
  tds: Tdatasource;
  tq: Tquery;

procedure TfrmCon_RepresMov.FazConsulta;
begin
  RepresMov := TRepresMov.Create;
  RepresMov.Consultar(tq, Rep_codigo, Repm_data);
  tq.open;
  RepresMov.free;
  dbgRepresMov.DataSource := tds;
  dbgRepresMov.Refresh;
end;

procedure TFrmCon_RepresMov.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Repm_sequencia := tq.fieldbyname('Repm_Sequencia').AsInteger;
  tds.free;
  tq.free;
end;

procedure TFrmCon_RepresMov.FormActivate(Sender: TObject);
begin
  inherited;
  if FileExists(caminho_personal + 'belquimica') then begin
    btnGravar.Visible := False;
  end;
  label1.caption := Rep_nome;
  tds := TDataSource.create(FrmCon_RepresMov);
  tq := Tquery.create(FrmCon_RepresMov);
  tq.databasename := dmint.db.databasename;
  tq.active := False;
  tds.DataSet := tq;
  fazconsulta;
end;

procedure TFrmCon_RepresMov.btnGravarClick(Sender: TObject);
var
  f1: TfrmCad_RepresMov;
begin
  inherited;
  f1 := TfrmCad_RepresMov.Create(self);
  f1.btnC_RepresMov.Visible := False;
  f1.ShowModal;
  f1.Free;
  FazConsulta;
end;

end.
